﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Common;
using System.Linq;
using System.Web;

namespace WebDemo.Data
{
    public class DBFactory
    {
        public static DbConnection CreateConnection(string dbkey)
        {
            ConnectionStringSettings connectionConfig = ConfigurationManager.ConnectionStrings[dbkey];
            DbProviderFactory factory = DbProviderFactories.GetFactory(connectionConfig.ProviderName);
            DbConnection conn = factory.CreateConnection();
            conn.ConnectionString = connectionConfig.ConnectionString;

            conn.Open();
            return conn;
        }
    }
}